package io.renren.modules.web.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.entity.ProjectCooperationEntity;
import io.renren.modules.sys.service.ProjectCooperationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;


/**
 * 
 *
 * @author zyj
 * @email 740916741@qq.com
 * @date 2019-01-11 10:50:32
 */
@RestController
@RequestMapping("web/projectcooperation")
public class WebProjectCooperationController {
    @Autowired
    private ProjectCooperationService projectCooperationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("projectcooperation:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = projectCooperationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("projectcooperation:info")
    public R info(@PathVariable("id") Integer id){
			ProjectCooperationEntity projectCooperation = projectCooperationService.selectById(id);

        return R.ok().put("projectCooperation", projectCooperation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("projectcooperation:save")
    public R save(@RequestBody ProjectCooperationEntity projectCooperation){
            projectCooperation.setCreateTime(new Date());
			projectCooperationService.insert(projectCooperation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("projectcooperation:update")
    public R update(@RequestBody ProjectCooperationEntity projectCooperation){
			projectCooperationService.updateById(projectCooperation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("projectcooperation:delete")
    public R delete(@RequestBody Integer[] ids){
			projectCooperationService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
